/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 *    
 */

package org.vineatoum.business.state;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import org.vineatoum.business.Cuve;
import org.vineatoum.business.state.abstraction.VinAbstract;
import org.vineatoum.exception.VinengineException;
import org.vineatoum.view.utils.jtablecustom.TableListener;


public class Raisin extends VinAbstract {
	private static Set<Raisin> raisins = new HashSet<Raisin>();
	private int vintage;
	private List<Recolte> recoltes = new ArrayList<Recolte>();
	
	public Raisin() {
		super();
		raisins.add(this);
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * @param vintage the vintage to set
	 */
	public void setVintage(int vintage) {
		this.vintage = vintage;
	}

	/**
	 * @return the vintage
	 */
	public int getVintage() {
		return vintage;
	}

	@Override
	public String toString() {
		String out = "---Raisin---- issu de " + origines.size() + " origines.";
		return out;
	}

	public static Set<Raisin> getCollection() {
		return raisins;
	}

	public Recolte newHarvest(float harvestPercentage) throws VinengineException {
		//TODO if(this.unharvestPercent - harvestPercentage >=0) {
			Recolte temp = new Recolte(this);
			recoltes.add(temp);
			origines.add(temp);
//			this.setUnharvestPercent(this.unharvestPercent - harvestPercentage);
			return temp;
//		} else {
//			throw new VinengineException("Can't create new Raisin. Percentage to harvest is too big");
//		}
	}

	@Override
	public TableListener getNewInstance() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Vector<String> getVectorColumns() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Vector<Object> getVectorData() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void updateField(String field, Object value) {
		// TODO Auto-generated method stub
		
	}
}
